#!/bin/bash
SHELL_DIR=$(cd "$(dirname "$0")" || exit; pwd)
COMMON_SHELL="$SHELL_DIR/common.sh"
# load common.sh, get install.info
source "${COMMON_SHELL}"
ASCEND_SECLOG="/var/log/ascend_seclog"
logFile="${ASCEND_SECLOG}/ascend_install.log"
rebuildLog="${ASCEND_SECLOG}/ascend_rebuild.log"
installInfo="/etc/ascend_install.info"
kernel_path="/lib/modules/`getKernelVer`/build"

# read Driver_Install_Path_Param from installInfo
UserName=$(getInstallParam "UserName" "${installInfo}")
UserGroup=$(getInstallParam "UserGroup" "${installInfo}")
# read Driver_Install_Path_Param from installInfo
Driver_Install_Path_Param=$(getInstallParam "Driver_Install_Path_Param" "${installInfo}")
# used by dkms source compile
SPECIFIC_SHELL="$SHELL_DIR/specific_func.inc"
VNPU_MODE_KEYWORD=("vnpu_host" "vnpu_docker_host" "vnpu_guest")

Driver_Install_Mode_Arr=("normal")

export kernelver=`getKernelVer`

CUR_DIR="$(dirname $(readlink -f "$0"))"
TOP_DIR="${CUR_DIR}/../../"
TAR_DIR="${TOP_DIR}/driver/host/"
SRC_DIR="${TOP_DIR}/driver/kernel/"
SRC_DIR_BAK="${TOP_DIR}/driver/kernel_bak/"
SCENE_INFO="${TOP_DIR}/driver/scene.info"

STRICT_MATCH=y
DO_REBUILD=n

log() {
    cur_date=`date +"%Y-%m-%d %H:%M:%S"`
    user_id=`id | awk '{printf $1}'`
    echo "[Driver] [$cur_date] [$user_id] "$1 >> $logFile
    return 0
}

drvEcho() {
    cur_date=`date +"%Y-%m-%d %H:%M:%S"`
    echo "[Driver] [$cur_date] $1"
}

exit_and_clean() {
    [ -e "${SRC_DIR_BAK}" ] && rm -rf "${SRC_DIR_BAK}"
    exit $1
}

creat_rebuild_log() {
    if [ -e "${rebuildLog}" ];then
        rm -f ${rebuildLog}
    fi
    touch ${rebuildLog}
    chmod -f 640 ${rebuildLog}
}

modversion_fuzzy_match() {
    primary_kernel_ver=$(echo $kernel_ver | awk -F [-+] '{print $1}')
    primary_ko_vermagic=$(echo $ko_vermagic | awk -F [-+] '{print $1}')
    if [ "$primary_kernel_ver"x != "$primary_ko_vermagic"x ];then
        log "[WARNING]Current kernel primary version($kernel_ver) is different from the driver($ko_vermagic)."
        DO_REBUILD=y
    fi
}

modversion_strict_match() {
    if [ "$kernel_ver"x != "$ko_vermagic"x ];then
        log "[WARNING]Driver ko vermagic($ko_vermagic) is different from the os($kernel_ver), need rebuild driver"
        DO_REBUILD=y
    fi
}

check_euleros() {
    source "${TOP_DIR}"/driver/script/common_func.inc
    source "${TOP_DIR}"/driver/scene.info

    get_system_info
    log "[INFO]HostOsName(${HostOsName})"
    if [ "${HostOsName}" == "EulerOS" ];then
        for item in ${os}
        do
            if echo $item | grep -i "^${HostOsName}$">/dev/null;then
                log "[INFO]OS($HostOsName) try fuzzy match"
                STRICT_MATCH=n
                return
            fi
        done
    fi
}

check_need_rebuild() {
    pcie_hdc_ko="${TAR_DIR}"/drv_pcie_hdc_host.ko
    kernel_ver=$(getKernelVer)
    ko_vermagic=$(modinfo "$pcie_hdc_ko" | grep vermagic | awk '{print $2}')

    if [ "${STRICT_MATCH}" == "y" ];then
        modversion_strict_match
    else
        modversion_fuzzy_match
    fi
}

check_path() {
    which gcc >/dev/null 2>&1
    if [ $? -ne 0 ];then
        drvEcho "[ERROR]gcc: command not found"
        log "[ERROR]gcc: command not found"
        exit 1
    fi
    which make >/dev/null 2>&1
    if [ $? -ne 0 ];then
        drvEcho "[ERROR]make: command not found"
        log "[ERROR]make: command not found"
        exit 1
    fi
    if [ ! -d "${SRC_DIR}" ];then
        log "[ERROR]${SRC_DIR} no exist, can not try rebuild ko"
        exit 1
    fi
    creat_rebuild_log
}

check_kernel_header() {
    drvEcho "[INFO]Please input your kernel absolute path or input [Q/q] to exit:"
    while true
    do
        read kernel_path
        if [ -d "${kernel_path}" ];then
            break
        elif [ "${kernel_path}" == "q" ] || [ "${kernel_path}" == "Q" ];then
            exit_and_clean 1
        fi
        drvEcho "[WARNING]${kernel_path} no exist or not a absolute path! input again or input [Q/q] to exit"
    done
}

get_user_input_yn() {
    local yn_flag=0
    while true
    do
        read yn
	if [ "${yn}" == "y" ] || [ "${yn}" == "Y" ];then
            break
        elif [ "${yn}" == "n" ] || [ "${yn}" == "N" ];then
            exit_and_clean 1
        else
            let yn_flag++
            if [ "${yn_flag}" -gt 5 ];then
                exit_and_clean 1
            fi
            drvEcho "[ERROR]Input error, please input [y/n] again!"
        fi
    done
}

strip_ko_auto() {
    which strip >/dev/null 2>&1
    if [ $? -ne 0 ];then
        return
    fi
    strip -S --remove-section=.note.gnu.build-id $1
}

update_driver_install_mode() {
    if [ -e "${SPECIFIC_SHELL}" ]; then
        for vkey in ${VNPU_MODE_KEYWORD[*]}
        do
            grep -q "mode_"${vkey} "${SPECIFIC_SHELL}" && \
                Driver_Install_Mode_Arr[${#Driver_Install_Mode_Arr[*]}]="${vkey}"
        done
    fi
}

rebuild_ko_auto() {
    local rename_ret=0
    cd ${SRC_DIR_BAK}
    update_driver_install_mode
    for Driver_Install_Mode in ${Driver_Install_Mode_Arr[*]}
    do
        export Driver_Install_Mode
	eval `cat dkms* | grep MAKE | awk -F ']=' '{print $2}'| sed 's/^"//' | sed 's/"$//' | sed "s#'##g"` >>${rebuildLog} 2>&1
        if [ $? -ne 0 ];then
            log "[WARNING]Build has something wrong by kernel path(${kernel_path})"
            make clean >>${rebuildLog} 2>&1
            return 1
        fi
        # rename stub ko
        if [ -e "vmng_host_stub/drv_virtmng_host.ko" ]; then
            mv vmng_host_stub/drv_virtmng_host.ko vmng_host_stub/drv_virtmng_host_stub.ko || rename_ret=1
        fi
        if [ -e "vascend_drv_stub/drv_vascend.ko" ]; then
            mv vascend_drv_stub/drv_vascend.ko vascend_drv_stub/drv_vascend_stub.ko || rename_ret=1
        fi
        if [ "${rename_ret}" -ne 0 ]; then
            log "[ERROR]Rename ko failed."
            make clean >>${rebuildLog} 2>&1
            return 1
        fi
    done

    ko_list=`find -name *.ko`
    for ko in ${ko_list[@]}
    do
        strip_ko_auto ${ko}
        cp -rf ${ko} ${TAR_DIR}
        if [ $? -ne 0 ]; then
            log "[ERROR]Copy ko failed."
            make clean >>${rebuildLog} 2>&1
            return 1
        fi
    done
    make clean >>${rebuildLog} 2>&1
    cd ${TOP_DIR}
}

rebuild_ko_manual() {
    check_kernel_header
    sed -ir "s#/lib/modules/\$(KERNEL_UNAME)/build#${kernel_path}#g" ${SRC_DIR_BAK}/Makefile
    drvEcho "[INFO]Rebuilding by kernel path(${kernel_path})"
    rebuild_ko_auto
    if [ $? -ne 0 ];then
        log "[ERROR]Rebuild failed by user kernel path(${kernel_path})."
        return 1
    fi
}

rebuild_ko_ci() {
    source ${SRC_DIR}/../script/binary_os_config.sh
    if [ ! -d "${ker_path}" ];then
        drvEcho "[WARNING]${ker_path} no exist or not a absolute path!"
        return 1
    fi
    sed -ir "s#/lib/modules/\$(KERNEL_UNAME)/build#${ker_path}#g" ${SRC_DIR_BAK}/Makefile
    drvEcho "[INFO]Rebuilding by kernel path(${ker_path})"
    rebuild_ko_auto
    if [ $? -ne 0 ];then
        log "[ERROR]Rebuild failed by user kernel path(${ker_path})."
        return 1
    fi
}

change_scene() {
    os_type=""
    os_version_num=""
    which lsb_release >/dev/null 2>&1
    if [ $? -eq 0 ];then
        os_type=`lsb_release -is | tr 'A-Z' 'a-z'`
        os_version_num=`lsb_release -rs | awk -F '.' '{print $1"."$2}'`
        [ $os_type == 'euleros' ] && os_version_num=`lsb_release -rs | awk -F '.' '{print $1}'`.`lsb_release -cs |tr -cd "[0-9] _"`
    fi

    sed -i "s/os=.*/os=${os_type}/g" ${SCENE_INFO}
    sed -i "s/os_version=.*/os_version=${os_version_num}/g" ${SCENE_INFO}
}

check_arch() {
    package_arch=`cat ${SCENE_INFO} | grep arch`
    ARCH_TEMP=$(arch)
    ARCH_TEMP=${ARCH_TEMP/_/-}
    if [[ ! $package_arch =~ $(arch) ]];then
        if [[ ! $package_arch =~ $ARCH_TEMP ]];then
            drvEcho "[WARNING]Arch mismatch, src package system is ${package_arch}, cur system is $(arch)."
            log "[WARNING]Arch mismatch, src package system is ${package_arch}, cur system is $(arch)."
        fi
    fi
}

create_src_dir_bak() {
    cp -rf ${SRC_DIR} ${SRC_DIR_BAK}
    cp -rf ${SRC_DIR_BAK}/Makefile_* ${SRC_DIR_BAK}/Makefile
}

special_os_repack_adapt() {
    ker_ver=$(uname -r)
    if [ "${HostOsName}"x == "Ubuntu"x -a "${HostOsVersion}"x == "22.04"x ]; then
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/pcievnic_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/hdc_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-type-limits/' ${SRC_DIR}/vascend_drv_stub/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/vmng_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/pcie_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-type-limits/' ${SRC_DIR}/vmng_vpc_drv/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/vmng_host_stub/Makefile
        sed -i 's/vdrv_dvpp_cmdlist"/vdrv_dvpp_cmdlist|drv_seclib_host"/' ${SRC_DIR}/../script/specific_func.inc
    fi
    # 1980b adapt for MT centos7.6+centos7.4
    if [ "${HostOsName}"x == "CentOS"x ]; then
        sed -i 's/-Werror//g' ${SRC_DIR}/event_sched/host/Makefile >>/dev/null 2>&1
        sed -i 's/EXTRA_CFLAGS += -fstrong-eval-order//' ${SRC_DIR}/dvpp_cmdlist/Makefile* >>/dev/null 2>&1
        sed -i 's/EXTRA_CFLAGS += -Wdate-time//' ${SRC_DIR}/dvpp_cmdlist/Makefile* >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall/ccflags-y += -Wall -Wno-unused-const-variable/' ${SRC_DIR}/dms/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-missing-braces/' ${SRC_DIR}/rms/trs_drv/cdqm/host/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-missing-braces/' ${SRC_DIR}/rms/trs_drv/lba/near/sia/adapt/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-missing-braces/' ${SRC_DIR}/rms/trs_drv/lba/near/sriov_sec_enhanced/adapt/Makefile >>/dev/null 2>&1
        sed -i 's/__WQ_LEGACY | WQ_MEM_RECLAIM/WQ_MEM_RECLAIM/g' ${SRC_DIR}/rms/trs_drv/trs_core/trs_hw_sqcq.c >>/dev/null 2>&1
        if which gcc >> /dev/null 2>&1; then
            gcc --version | grep 4.8.5 >>/dev/null 2>&1
            if [ $? -eq 0 ]; then
                sed -i 's/EXTRA_CFLAGS += -Wno-error=incompatible-pointer-types//' "$sourcedir"/kernel/dvpp_cmdlist/Makefile* >>/dev/null 2>&1
            fi
        fi
    fi
    if [ "${HostOsName}"x == "CentOS"x -a "${HostOsVersion}"x == "7.6.1810"x ] && [ "$(uname -m)" = "x86_64" ]; then
        sed -i 's/__GFP_RETRY_MAYFAIL/__GFP_REPEAT/g' ${SRC_DIR}/rms/trs_drv/trs_core/trs_sqcq_map.c >>/dev/null 2>&1
        sed -i 's/__GFP_RETRY_MAYFAIL/__GFP_REPEAT/g' ${SRC_DIR}/rms/trs_drv/lba/near/sia/adapt/near_comm/trs_host_chan/trs_chan_near_ops_mem.c >>/dev/null 2>&1
    fi
    if [ "${HostOsName}"x == "Kylin"x -a "${HostOsVersion}"x == "V10"x ]; then
        sed -i 's/EXTRA_CFLAGS += -fstack-protector-all/EXTRA_CFLAGS += -fno-stack-protector/' $(grep "EXTRA_CFLAGS += -fstack-protector-all" -rl ${SRC_DIR}) >>/dev/null 2>&1
    fi
    if [ "${HostOsName}"x == "BigCloud"x -a "${HostOsVersion}"x == "8.2"x ]; then
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-incompatible-pointer-types -Wno-implicit-function-declaration/' ${SRC_DIR}/pcie_host/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/svm_agent_host/host/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/svmdrv/pmaster/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/svmdrv/pcievnic_host/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/pcievnic_host/Makefile >>/dev/null 2>&1
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/svmdrv/vmaster/Makefile >>/dev/null 2>&1
        sed -i 's/pci_cleanup_aer_uncorrect_error_status(pdev);/pci_aer_clear_nonfatal_status(pdev);/' ${SRC_DIR}/pcie_host/devdrv_pci.c >>/dev/null 2>&1
    fi
    if [ "${HostOsName}"x == "SLES"x -a "${HostOsVersion}"x == "15.4"x ] || [ "${HostOsName}"x == "SLED"x -a "${HostOsVersion}"x == "15.4"x ]; then
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/pcie_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/hdc_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/vmng_host/Makefile
        sed -i 's/EXTRA_CFLAGS += -Wno-unused-parameter/EXTRA_CFLAGS += -Wno-unused-parameter -Wno-shadow/' ${SRC_DIR}/dvpp_cmdlist/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-type-limits/' ${SRC_DIR}/vascend_drv_stub/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-type-limits/' ${SRC_DIR}/vmng_vpc_drv/Makefile
        sed -i 's/ccflags-y += -Wall -Werror/ccflags-y += -Wall -Werror -Wno-incompatible-pointer-types/' ${SRC_DIR}/vascend_drv/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/pcievnic_host/Makefile
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-empty-body -Wno-type-limits/' ${SRC_DIR}/vmng_host_stub/Makefile
        sed -i '/mode_vnpu_guest/d' ${SRC_DIR}/../script/specific_func.inc
    fi
    if [ "${HostOsName}"x == "uos"x -a "${HostOsVersion}"x == "20 SP1"x ]; then
        sed -i 's/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body/ccflags-y += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-empty-body -Wno-unused-function/' ${SRC_DIR}/pcie_host/Makefile
    fi
    if [ "${HostOsName}"x == "jariworks"x -a "${HostOsVersion}"x == "4.1.2"x ]; then
        sed -i 's/#include <linux\/rwlock.h>//' $(grep "#include <linux\/rwlock.h>" -rl ${SRC_DIR}) >>/dev/null 2>&1
        sed -i 's/#include <linux\/rwlock_types.h>//' $(grep "#include <linux\/rwlock_types.h>" -rl ${SRC_DIR}) >>/dev/null 2>&1
    fi
    if [ "${ker_ver}"x == "4.19.90-25.10.v2101.ky10.aarch64"x -o "${ker_ver}"x == "4.19.90-25.12.v2101.ky10.aarch64"x ]; then
        sed -i '/EXTRA_CFLAGS += -fno-common/a EXTRA_CFLAGS += -Wno-error=incompatible-pointer-types' ${SRC_DIR}/dvpp_cmdlist/Makefile* >>/dev/null 2>&1
    fi
}

# check os and match modversion
check_euleros
# force use for repack package
if [ x"$1" == x"--force" ];then
    DO_REBUILD=y
    check_arch
    change_scene
else
    check_need_rebuild
fi
if [ "${DO_REBUILD}" == "n" ];then
    exit_and_clean 0
fi

# start rebuild
check_path
special_os_repack_adapt
if [ "${ci_envir}"x == "true"x ]; then
    create_src_dir_bak
    rebuild_ko_ci
    if [ $? -ne 0 ];then
        log "[ERROR]rebuild failed, detail in ${rebuildLog}"
        exit_and_clean 1
    fi
else
    drvEcho "[INFO]Rebuilding by kernel path(/lib/modules/`getKernelVer`/build), detail in ${rebuildLog}"
    create_src_dir_bak
    rebuild_ko_auto
    if [ $? -ne 0 ];then
        log "[WARNING]Rebuild ko has something wrong, detail in ${rebuildLog}"
        drvEcho "[WARNING]Rebuild ko has something wrong, detail in ${rebuildLog}"
        drvEcho "[INFO]Do you want to try build driver after input kernel absolute path? [y/n]:"
        get_user_input_yn
        rebuild_ko_manual
        if [ $? -ne 0 ];then
            log "[ERROR]Manual build failed, detail in ${rebuildLog}"
            exit_and_clean 1
        fi
    fi
fi

log "[INFO]Rebuild ko success"
exit_and_clean 0
